package com.sanqing.main;

import com.sanqing.model.BookType;

import javax.swing.*;
import javax.swing.event.ListDataListener;
import java.util.ArrayList;

public class ComBoxMyModel implements ComboBoxModel {
    private ArrayList<BookType> lst = null;
    private Object selectObject;

    public void setLst(ArrayList<BookType> lst) {
        this.lst = lst;
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selectObject = anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selectObject;
    }

    @Override
    public int getSize() {
        if (lst != null) {
            return lst.size();
        }
        return 0;
    }

    @Override
    public Object getElementAt(int index) {
        if (lst != null) {
            return lst.get(index);
        }
        return null;
    }

    @Override
    public void addListDataListener(ListDataListener l) {

    }

    @Override
    public void removeListDataListener(ListDataListener l) {

    }
}
